package pers.chao.logger.properties;

import cn.hutool.core.util.RuntimeUtil;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * Description: 动态设置自定义Logback的相关配置
 *
 * @author W.Chao
 * @date 2020/11/21 19:09
 **/
@ConfigurationProperties(prefix = "logger.logback")
public class LogbackLogbackProperties {
	/**
	 * 日志文件路径
	 */
	private String logPath = System.getProperties().getProperty("os.name").equals("Linux") ?
			RuntimeUtil.execForStr("echo ~") : System.getProperty("user.home");
	/**
	 * 日志文件前缀
	 */
	private String logNamePrefix = "";
	/**
	 * 单个日志文件大小
	 */
	private String singleMaxFileSize = "10MB";
	/**
	 * 总日志文件大小限制
	 */
	private String totalMaxFileSize = "1GB";
	/**
	 * 日志文件保留时间
	 */
	private int maxHistory = 10;

	public String getLogPath() {
		return logPath;
	}

	public String getLogNamePrefix() {
		return logNamePrefix;
	}

	public String getSingleMaxFileSize() {
		return singleMaxFileSize;
	}

	public String getTotalMaxFileSize() {
		return totalMaxFileSize;
	}

	public int getMaxHistory() {
		return maxHistory;
	}

	public void setLogPath(String logPath) {
		this.logPath = logPath;
	}

	public void setLogNamePrefix(String logNamePrefix) {
		this.logNamePrefix = logNamePrefix;
	}

	public void setSingleMaxFileSize(String singleMaxFileSize) {
		this.singleMaxFileSize = singleMaxFileSize;
	}

	public void setTotalMaxFileSize(String totalMaxFileSize) {
		this.totalMaxFileSize = totalMaxFileSize;
	}

	public void setMaxHistory(int maxHistory) {
		this.maxHistory = maxHistory;
	}
}
